
#include <complex>
struct Mandelbrot_Set_Info{
    double centen_x,centen_y;
    double x_scale,y_scale;
    int width,height;
};
template<class T>
struct MandelbrotFactory{
    static T* CreateImage(Mandelbrot_Set_Info const & parame){
        T * p=new T(parame.width,parame.height);
        double x_left=parame.centen_x-(parame.width-1)/2*parame.x_scale;
        double y_top=parame.centen_y+(parame.height-1)/2*parame.y_scale;
        for(int i=0;i<parame.height;++i){
            for(int j=0;j<parame.width;++j){
                int k=0;
                std::complex<double> z(0,0);
                std::complex<double> z0(x_left+j*parame.x_scale,y_top-i*parame.y_scale);
                while(k++<200 && std::abs(z)<100){
                    z=z*z+z0;
                }
                if(k>=200) p->SetValue(i,j, 1);
            }
        }
        return p;
    }
};
